﻿@model OrderControllerModel.Index
<div class="my-main">
    <div class="ui-box  ui-box-alpha">
        <div class="ui-box-head">
            <div class="ui-box-head-border">
                <div class="ui-box-head-title">
                    订单中心</div>
                <a href="#" class="ui-box-head-more">去购物</a>
            </div>
        </div>
        <div class="ui-box-container">
            <div class="ui-box-content">
                <div class="row-fluid">
                    <div class="span4">
                        <label>
                            订单编号：<input type="text" name="orderid" class="input-medium" /></label>
                    </div>
                    <div class="span4">
                        <label>
                            开始时间：<input type="text" name="itemname" class="input-medium" />
                        </label>
                    </div>
                    <div class="span4">
                        <label>
                            订单状态：<select name="status" class="input-medium">
                                <option value="0">全部</option>
                            </select></label>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span4">
                        <label>
                            商品名称：<input type="text" name="itemname" class="input-medium" /></label>
                    </div>
                    <div class="span4">
                        <label>
                            结束时间：<input type="text" name="itemname" class="input-medium" />
                        </label>
                    </div>
                    <div class="span4">
                        <label>
                            评价状态：<select name="status" class="input-medium">
                                <option value="0">全部</option>
                            </select></label>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span4">
                        <label>
                            买家昵称：<input type="text" name="itemname" class="input-medium" /></label>
                    </div>
                    <div class="offset1 span3">
                        <button type="button" class="btn">
                            搜 索</button>
                    </div>
                    <div class="offset1 span3">
                        <button type="button" class="btn">
                            导 出</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="ui-box-container-noborder">
            <div class="ui-box-content">
            </div>
        </div>
        <div class="ui-box-container-noborder">
            <div class="tabbable">
                <ul class="nav nav-tabs" style="padding-left: 40px;">
                    <li class="active"><a href="#1">我的订单</a></li>
                    <li><a href="/order/auction">竞购订单</a></li>
                </ul>
                <div class="tab-content">
                    <div class="tab-pane active">
                        <table class="ui-table ui-table-inbox ui-table-alpha">
                            <thead>
                                <tr>
                                    <th style="width: 250px;">
                                        商品信息
                                    </th>
                                    <th>
                                        单价(元)
                                    </th>
                                    <th>
                                        数 量
                                    </th>
                                    <th>
                                        售 后
                                    </th>
                                    <th>
                                        买 家
                                    </th>
                                    <th>
                                        实收款(元)
                                    </th>
                                    <th>
                                        订单状态
                                    </th>
                                    <th>
                                        评 价
                                    </th>
                                </tr>
                            </thead>
                            @Model.Orders.Each(@<tbody class="@(item.Item.Status == OrderStatus.Pending ? "item-pending" : "item")">
                                <tr class="item-header">
                                    <td colspan="5" class="text-align-left">
                                        <input type="checkbox" class="checkbox" value="@(item.Item.Id)" style="margin: 0;"/>
                                        <span>订单编号：@(item.Item.Id)</span>
                                    </td>
                                    <td colspan="2">
                                        成交时间：@(item.Item.CreatedOn.ToString("yyyy-MM-dd HH:mm:ss"))
                                    </td>
                                    <td>
                                        <span class="pull-right"><a href="javascript:void(0);" data-rel="popover" data-toggle="popover"
                                            data-trigger="hover" data-placement="left" data-title="备 忘" data-content="@(item.Item.SellerMemo.IsNullOrEmpty() ? "暂时没有备忘信息！" : item.Item.SellerMemo)">
                                            <i class="icon-flag" style="color: red;"></i></a></span>
                                    </td>
                                </tr>
                                @for (var i = 0; i < item.Item.OrderItems.Count; i++)
                                {
                                    var temp = item.Item.OrderItems[i];
                                    <tr @(i < item.Item.OrderItems.Count - 1 ? "class=light" : string.Empty)>
                                        <td class="col  @(item.Item.OrderItems.Count > 1 ? "multiple light" : string.Empty)">
                                            <div class="media">
                                                <a class="pull-left" href="" target="_blank">
                                                    <img data-src="holder.js/64x64" class="media-object" alt="64x64" style="width: 64px;
                                                        height: 64px;" src="">
                                                </a>
                                                <div class="media-body">
                                                    <h5 class="media-heading">
                                                        @(temp.Title)
                                                    </h5>
                                                    <p>
                                                        @foreach (var o in temp.GetProperties().OrderBy(o => o.Length))
                                                        {
                                                            @(o)<br />
                                                        }
                                                    </p>
                                                </div>
                                            </div>
                                        </td>
                                        <td class="col @(item.Item.OrderItems.Count > 1 ? "multiple light" : string.Empty)">
                                            @(temp.Price.ToString("N"))
                                        </td>
                                        <td class="col @(item.Item.OrderItems.Count > 1 ? "multiple light" : string.Empty)">
                                            @(temp.Quantity)
                                        </td>
                                        <td class="col @(item.Item.OrderItems.Count > 1 ? "light" : string.Empty)">
                                            @if (!temp.RefundId.IsNullOrEmpty() && temp.RefundStatus.HasValue)
                                            {
                                                <p>
                                                    <a href="/refund/detail/@temp.RefundId">退 款</a></p>
                                            }
                                        </td>
                                        @if (i == 0)
                                        {
                                            <td class="col" @(item.Item.OrderItems.Count > 1 ? "rowspan=" + (item.Item.OrderItems.Count) : string.Empty)>
                                                <p>
                                                    <span>@(item.Item.BuyerNick)</span>&nbsp;<a title="查询该买家订单" href="javascript:void(0);"><i
                                                        class="icon-filter"></i></a>
                                                </p>
                                            </td>
                                            <td class="col" @(item.Item.OrderItems.Count > 1 ? "rowspan=" + (item.Item.OrderItems.Count) : string.Empty)>
                                                <p>
                                                    <strong>@(item.Item.Total.ToString("N"))</strong></p>
                                                @if (item.Item.Postage == 0)
                                                {
                                                    <p>
                                                        <span>免运费</span></p>
                                                }
                                                else
                                                {
                                                    <p>
                                                        <span>含快递：@(item.Item.Postage.ToString("N"))</span></p>
                                                }
                                                <p>
                                                    <span>订单优惠：@(item.Item.Discount.ToString("N"))</span></p>
                                            </td>
                                            <td class="col" @(item.Item.OrderItems.Count > 1 ? "rowspan=" + (item.Item.OrderItems.Count) : string.Empty) >
                                                @if (item.Item.Status == OrderStatus.Pending || item.Item.Status == OrderStatus.WaitBuyerPay)
                                                {
                                                    <p>
                                                        <a href="/order/detail/@(item.Item.Id)" target="_blank">等待买家付款</a></p>
                                                    <p>
                                                        <a data-trigger="modal" href="/order/cancel/@(item.Item.Id)" data-title="关闭交易">关闭交易</a></p>
                                                }
                                                else if (item.Item.Status == OrderStatus.WaitSellerSend)
                                                {
                                                    <p>
                                                        <a href="/order/detail/@(item.Item.Id)" target="_blank">已付款待发货</a></p>
                                                    <p>
                                                        <a href="@(WebSite.Logistics)/home/consign/@(item.Item.Id)" target="_blank">发 货</a></p>
                                                    
                                                }
                                                else if (item.Item.Status == OrderStatus.SellerSendPart)
                                                {
                                                    <p>
                                                        <a class="order-status" href="/order/detail/@(item.Item.Id)" target="_blank">部分发货</a>
                                                    </p>
                                                    <p>
                                                        <a href="@(WebSite.Logistics)/home/consign/@(item.Item.Id)" target="_blank">发 货</a></p>
                                                }
                                                else if (item.Item.Status == OrderStatus.WaitBuyerConfirm)
                                                {
                                                    <p>
                                                        <a class="order-status" href="/order/detail/@(item.Item.Id)" target="_blank">已发货待确认</a>
                                                    </p> <p>
                                                        <a data-trigger="modal" href="/order/close/@(item.Item.Id)" data-title="延长收货时间">延长收货时间</a></p> 
                                                }
                                                else if (item.Item.Status == OrderStatus.Canceled)
                                                {
                                                    <a class="order-status" href="/order/detail/@(item.Item.Id)" target="_blank">交易关闭</a>
                                                }
                                                else if (item.Item.Status == OrderStatus.Finished)
                                                {
                                                    <a class="order-status" href="/order/detail/@(item.Item.Id)" target="_blank">交易成功</a>
                                                }
                                            </td>
                                            <td class="ui-table-action" @(item.Item.OrderItems.Count > 1 ? "rowspan=" + (item.Item.OrderItems.Count) : string.Empty)>
                                                @if (item.Item.BuyerRate && item.Item.SellerRate)
                                                {
                                                    <p>
                                                        <span>双方已评</span>
                                                    </p>
                                                }
                                                <p>
                                                    <a data-trigger="modal" href="/order/memo/@(temp.OrderId)"
                                                                      data-title="备忘">备 忘</a>
                                                </p>
                                            </td>
                                        }
                                    </tr>
                                }
                                <tr class="item-footer">
                                    <td colspan="8">
                                    </td>
                                </tr>
                            </tbody>)
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () { //Sk.Passport.Fun.validateLogin(window);
        $('[data-rel="popover"]').popover();
    });
</script>
